home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 1995 #5 & #6 / Amiga Plus CD - 1995 - No. 5 and 6.iso / pd / tools / reqtools / rexxreqtools / demo.rexx next >
OS/2 REXX Batch file  |  1995-08-25  |  10KB  |  256 lines

  1. /*
  2. **$VER: Demo.rexx 37.18 (6.6.93)
  3. **
  4. **  $Filename: Demo.rexx $
  5. **  $Version: 37.18 $
  6. **  $Date: 6.6.93 $
  7. **  $Creation: 2.1.93 $
  8. **
  9. **  Demo ARexx script for rexxreqtools.library
  10. **
  11. **  (C) Copyright 1993 Rafael D'Halleweyn
  12. */
  13.  
  14. /* NOTE: A Comma at the end of a line is no argument seperator but contituation
  15.  *       character for a statement that continues on the next line!!
  16.  */
  17.  
  18. NL = '0a'x
  19.  
  20. call addlib("rexxreqtools.library", 0, -30, 0)
  21.  
  22. call rtezrequest( "RexxReqTools 1.2 Demo" || NL ||,
  23.                   "~~~~~~~~~~~~~~~~~~~~~" || NL ||,
  24.                   "'rexxreqtools.library' offers several" || NL ||,
  25.                   "different types of requesters:", "Let's see them")
  26.  
  27.  
  28. call rtezrequest( "But first you'll have to pick the font" || NL ||, 
  29.                   "that you want to use for this demo.")
  30. call rtfontrequest("Pick font", , 'rtfo_flags=freqf_fixedwidth', font)
  31. if font then
  32.   fonttag = "rt_font=" || font.name || "/" || font.height
  33. else
  34.   fonttag = ""
  35.  
  36.  
  37. /* STRING REQUESTER */
  38.  
  39. call rtezrequest( "NUMBER 1:" || NL ||,
  40.                   "String requester" || NL ||,
  41.                   "function: rtgetstring()", "Show me" , , fonttag)
  42.  
  43. buffer = rtgetstring("A bit of text", , "Enter anything:", , fonttag)
  44. if buffer == "" then
  45.   call rtezrequest("You entered nothing!", "I'm sorry", , fonttag)
  46. else
  47.   call rtezrequest( "You entered this string:" || NL ||,
  48.                     "'" || buffer || "'.", "So I did", , fonttag)
  49.  
  50. call rtgetstring( , "These are two new features of ReqTools 2.0:" || NL ||,
  51.                     "Text above the entry gadget and more than" || NL ||,
  52.                     "one response gadget.", "Enter anything:",,
  53.   " _Ok |New _2.0 feature!|_Cancel", fonttag)
  54. if rtresult == 2 then call rtezrequest( "Yep, this is a new" || NL ||,
  55.                                         "ReqTools 2.0 feature!", "Oh boy!",,
  56.                                        , fonttag)
  57.  
  58. call rtgetstring(buffer, "New is also the ability to switch off" || NL ||,
  59.                          "the backfill pattern. You can also center" || NL ||,
  60.                          "the text above the entry gadget." || NL ||,
  61.                          "These new features are also available" || NL ||,
  62.                          "in the rtgetlong() requester.",,
  63.   "Enter anything:"," _Ok |_Abort|_Cancel",,
  64.   fonttag,
  65.   "rtgs_backfill = false rtgs_flags = gsreqf_centertext|gsreqf_highlighttext")
  66. if rtresult == 2 then
  67.   call rtezrequest( "What!! You pressed abort!?!" || NL ||,
  68.                     "You must be joking :-)", "Ok, continue", , fonttag)
  69.  
  70.  
  71. /* NUMBER REQUESTER */
  72.  
  73. call rtezrequest( "NUMBER 2:" || NL ||,
  74.                   "Number requester" || NL ||,
  75.                   "function: rtgetlong()", "Show me", , fonttag)
  76.  
  77. long = rtgetlong(, , "Enter a number:", , fonttag,
  78.                                           "rtgl_min = -666 rtgl_max = 666")
  79. if rtresult == 0 then
  80.   call rtezrequest("You entered nothing!", "I'm sorry", , fonttag)
  81. else
  82.   do
  83.     text =         "The number you entered was:" || NL
  84.     text = text || long
  85.     if long == 666 then text = text "(you devil!)"
  86.     if long == -666 then text = text "(you negative devil!)"
  87.     call rtezrequest(text, "So it was", , fonttag)
  88.   end
  89.  
  90.  
  91. /* MESSAGE REQUESTER */
  92.  
  93. call rtezrequest( "NUMBER 3:" || NL ||,
  94.                   "Message requester, the requester" || NL ||,
  95.                   "you've been using all the time!" || NL ||,
  96.                   "function: rtezrequest()", "Show me more", , fonttag)
  97.  
  98. call rtezrequest( "Simplest usage: some body text" || NL ||,
  99.                   "and a single centered gadget.", "Got it", , fonttag)
  100.  
  101. do while rtezrequest( "You can also use two gadgets" || NL ||,
  102.                       "to ask the user something." || NL ||,
  103.                       "Do you understand?", "Of course|Not really", , fonttag) == 0
  104.   call rtezrequest("You are not one of the brightest are you?",,
  105.         "Let me try again", , fonttag)
  106. end
  107.  
  108. call rtezrequest("Great, we'll continue then.", "Fine", , fonttag)
  109.  
  110. call rtezrequest( "You can also put up a requester" || NL ||,
  111.                   "with three choices:" || NL ||,
  112.                   "How do you like the demo so far ?",,
  113.                   "_Great|_So so|_Rubbish", , fonttag)
  114. if rtresult == 0 then
  115.   call rtezrequest( "Too bad, we really hoped" || NL ||,
  116.                     "you would like it better.", "So what", , fonttag)
  117. if rtresult == 1 then
  118.   call rtezrequest("We're glad you like it so much.", "Fine", , fonttag)
  119. if rtresult == 2 then
  120.   call rtezrequest( "Maybe if you run the demo" || NL ||,
  121.                     "again you'll REALLY like it!", "Perhaps", , fonttag)
  122.  
  123. call rtezrequest( "The number of responses is not limited to" || NL ||,
  124.                   "three as you can see. The gadgets are labeled" || NL ||,
  125.                   "with the return code from rtezrequest()." || NL ||,
  126.                   "Pressing Return will choose 4, note that" || NL ||,
  127.                   "4's button text is printed in boldface.",,
  128.   "1|2|3|4|5|0", , fonttag "rtez_defaultresponse = 4")
  129.  
  130. call rtezrequest("You picked '" || rtresult || "'.", "How true", , fonttag)
  131.  
  132. if rtezrequest( "It is also possible to pass extra IDCMP flags" || NL ||,
  133.                 "that will satisfy rtezrequest(). This requester" || NL ||,
  134.                 "has had 'idcmp_diskinserted' passed to it." || NL ||,
  135.                 "(Try inserting a disk).", "Continue", ,,
  136.     fonttag "rt_idcmpflags = idcmp_diskinserted") == 0 then
  137.   call rtezrequest("You used the 'Continue' gadget.", "I did", , fonttag)
  138. else
  139.   call rtezrequest("You inserted a disk.", "I did", , fonttag)
  140.  
  141. call rtezrequest( "Finally, it is possible to specify the position of the" || NL ||,
  142.                   "requester." || NL ||,
  143.                   "E.g. at the top left of the screen, like this." || NL ||,
  144.                   "This works for all requesters, not just rtezrequest()!",,
  145.   "Amazing", , fonttag "rt_reqpos = reqpos_topleftscr")
  146.  
  147. call rtezrequest( "Alternatively, you can center" || NL ||,
  148.                   "the requester on the screen." || NL ||,
  149.                   "Check out 'rexxreqtools.doc'" || NL ||,
  150.                   "or 'rexxreqtools.guide' for" || NL ||,
  151.                   "all the possibilities.", "I'll do that", ,,
  152.   fonttag "rt_reqpos = reqpos_centerscr")
  153.  
  154.  
  155. /* FILE REQUESTER */
  156.  
  157. call rtezrequest( "NUMBER 4:" || NL ||,
  158.                   "File requester" || NL ||,
  159.                   "function: rtfilerequest()", "Demonstrate", , fonttag)
  160.  
  161. filename = rtfilerequest(, , "Pick a file" , , fonttag "rtfi_buffer = true")
  162. if rtresult == 0 then
  163.   call rtezrequest("You didn't pick a file.", "No", , fonttag)
  164. else
  165.   call rtezrequest("You picked the file:" || NL || filename, "Right", , fonttag)
  166.  
  167. call rtezrequest( "The file requester has the ability" || NL ||,
  168.                   "to allow you to pick more than one" || NL ||,
  169.                   "file (use Shift to extend-select)." || NL ||,
  170.                   "Note the extra gadgets you get.", "Interesting", , fonttag)
  171.  
  172. filename = rtfilerequest(, , "Pick some files", ,,
  173.             fonttag "rtfi_flags = freqf_multiselect")
  174. if rtresult == 1 then
  175.   call rtezrequest( "You selected" rtresult.count "files, " || NL ||,
  176.                     "this is the first one:" || NL ||,
  177.                     rtresult.1, "Aha", , fonttag)
  178.  
  179. call rtezrequest( "The file requester can be used" || NL ||,
  180.                   "as a directory requester as well.", "Let's see that", ,,
  181.                    fonttag)
  182.  
  183. dirname = rtfilerequest(, , "Pick a directory", ,,
  184.             fonttag "rtfi_flags = freqf_nofiles")
  185. if rtresult == 0 then
  186.   call rtezrequest("You didn't pick a directory.", "No", , fonttag)
  187. else
  188.   call rtezrequest("You picked the directory:" || NL || dirname, "Right", ,,
  189.         fonttag)
  190.  
  191.  
  192. /* FONT REQUESTER */
  193.  
  194. call rtezrequest( "NUMBER 5:" || NL ||,
  195.                   "Font requester" || NL ||,
  196.                   "function: rtfontrequest()", "Show", , fonttag)
  197.  
  198. call rtfontrequest("Pick a font", , fonttag "rtfo_flags = freqf_style")
  199. if rtresult == 0 then
  200.   call rtezrequest("You canceled." || NL || "Was there no font you liked ?",,
  201.          "Nope", , fonttag)
  202. else
  203.   call rtezrequest( "You picked the font:" || NL ||,
  204.                     rtresult.name "size" rtresult.height, "Right", , fonttag)
  205.  
  206.  
  207. /* PALETTE REQUESTER */
  208.  
  209. call rtezrequest( "NUMBER 6:" || NL ||,
  210.                   "Palette requester" || NL ||,
  211.                   "function: rtpaletterequest()", "Proceed", , fonttag)
  212.  
  213. color = rtpaletterequest(, "Change palette", fonttag)
  214. if rtresult == -1 then
  215.   call rtezrequest("You canceled." || NL || "No nice colors to be picked ?",,
  216.         "Nah", , fonttag)
  217. else
  218.   call rtezrequest("You picked color number" color, "Sure did", , fonttag)
  219.  
  220.  
  221. /* VOLUME REQUESTER */
  222.  
  223. call rtezrequest( "NUMBER 7:" || NL ||,
  224.                   "Volume requester" || NL ||,
  225.                   "function: rtfilerequest() with" || NL ||,
  226.                   "          rtfi_volumerequest tag.", "Show me", , fonttag)
  227.  
  228. volumename = rtfilerequest(, , "Pick a volume", ,,
  229.               fonttag "rtfi_volumerequest = 0")
  230. if rtresult == 0 then
  231.   call rtezrequest("You didn't pick a volume.", "I did not", , fonttag)
  232. else
  233.   call rtezrequest("You picked the volume:" || NL || volumename, "Right", ,,
  234.         fonttag)
  235.  
  236.  
  237. /* SCREENMODE REQUESTER */
  238.  
  239. call rtezrequest( "NUMBER 8:" || NL ||,
  240.                   "Screenmode requester" || NL ||,
  241.                   "function: rtscreenmoderequest().", "Let's have a look", ,,
  242.                   fonttag)
  243. screenmode = rtscreenmoderequest( "Pick screentype", ,,
  244.               fonttag "rtsc_flags = screqf_sizegads|screqf_depthgad", screen)
  245. if screenmode ~= "" then
  246.   call rtezrequest( "So you'd like to open a" || NL ||,
  247.                     screen.name "screen", "That's right", , fonttag)
  248. else
  249.   call rtezrequest( "Don't you have the right monitor ?", " No ", , fonttag)
  250.  
  251.  
  252. call rtezrequest("That's it!" || NL || "Hope you enjoyed the demo",,
  253.       "Sure did", , fonttag)
  254.  
  255. call rtfreefilebuffer()
  256.